package com.sky.mapper.user;

import com.sky.dto.OrdersPageQueryDTO;
import com.sky.pojo.OrderDetail;
import com.sky.pojo.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface HistoryOrdersMapper {

    List<Orders> selectHistoryOrders(OrdersPageQueryDTO ordersdTO);

    @Select("select * from order_detail where order_id = #{id}")
    List<OrderDetail> selectOrderDetail(Long id);

    List<Orders> selectCanCancelOrde(OrdersPageQueryDTO ordersdTO);
    @Select("select * from orders where id = #{orderId}")
    Orders selectOrderInfor(Long orderId);
    @Update("update orders set status = #{status} ,pay_status = #{payStatus} where id = #{orderId}; ")
    void cancleOrder(Orders orders);
    @Insert("insert into orders  (id, number, status, user_id, address_book_id, order_time, checkout_time, pay_method, pay_status, amount, remark, phone, address, user_name, consignee, cancel_reason, rejection_reason, cancel_time, estimated_delivery_time, delivery_status, delivery_time, pack_amount, tableware_number, tableware_status, meal_time, shop_id, delivery_fee) \n" +
            "                values (#{id},#{number},#{status},#{userId},#{addressBookId},#{orderTime},#{checkoutTime},#{payMethod},#{payStatus},#{amount},#{remark},#{phone},#{address},#{userName},#{cancelReason},#{rejectionReason},#{cancelTime},#{estimatedDeliveryTime},#{deliveryStatus},#{deliveryTime},#{packAmount},#{tablewareNumber},#{id},#{tablewareStatus},#{mealTime},#{shopId},#{deliveryFee} )")
    void orderAgain(Orders newOrder);
    @Select("select user_name  from orders where id = #{id}")
    String selectUserName(Long id);
}
